#!/bin/bash

trainset="$1"
testset="$2"

params=('2' '2 3 4 5 6 7 8' '2 3 4' '1 5')

accfile=pred.acc
rmsfile=pred.rms
rocfile=pred.roc

rm -f $accfile $rmsfile $rocfile

for b in 1 # 10
do
    for g in 0.1 # 0
    do
        for t in 15 # 30
        do
            for k in 0 1 3
            do
                for p in ${params[$k]}
                do
                    sig="-b=$b-g=$g-t=$t-k=$k-p=$p"
                    echo "training model with -b $b -g $g -t $t -k $k -p $p"
                    ./vplearn -b $b -g $g -t $t -k $k -p $p -m model$sig $trainset
                    echo "valdating model"
                    ./vpclassify -m model$sig -o pred$sig $testset
                    echo -n "$sig-voted " >> $accfile
                    colex 1 2 < pred$sig | perf -ACC -t 0 >> $accfile
                    echo -n "$sig-avg " >>  $accfile
                    colex 1 3 < pred$sig | perf -ACC -t 0 >> $accfile
                    echo -n "$sig-voted " >> $rocfile 
                    colex 1 2 < pred$sig | perf -ROC >> $rocfile
                    echo -n "$sig-avg " >> $rocfile
                    colex 1 3 < pred$sig | perf -ROC >> $rocfile
                    echo -n "$sig-voted " >> $rmsfile 
                    python sillycal.py < pred$sig | colex 1 2 | perf -RMS >> $rmsfile
                    echo -n "$sig-avg " >> $rmsfile
                    python sillycal.py < pred$sig | colex 1 3 | perf -RMS >> $rmsfile
                done
            done
        done
    done
done
